<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>路由学习-开始</title>
    <script src="../js/vue.js"></script>
    <script src="../js/vue-router.js"></script>
</head>
<body>
    <div id="app">
        <!-- 路由触发入口-->
        <router-link to="/user/foo">Go to Foo</router-link>
        <router-link to="/user/bar">Go to bar</router-link>

        <!-- 路由出口 -->
        <!-- 路由匹配到的组件将渲染在这里 -->
        <router-view></router-view>
    </div>


</body>
<script>
    const User = {template: '<div>User: {{ $route.params.id }}</div>'};
    const router = new VueRouter({
        routes: [
            // 动态路径参数 以冒号开头
            { path: '/user/:id', component: User }
        ]
    });
    const app = new Vue({
        el:"#app",
        router:router
    });
</script>
</html>